home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / AudioApps / Resound / ChangeFrequencyNoTimeModule.m < prev    next >
Text File  |  1992-12-20  |  3KB  |  142 lines

  1.  
  2.  
  3. #import "ChangeFrequencyNoTimeModule.h"
  4. #import "Imports.h"
  5.  
  6. @implementation ChangeFrequencyNoTimeModule
  7.  
  8. - Double:sender
  9. {
  10.     
  11.         [TheModuleController RunCompactPanel:self];
  12.         [[TheModuleController CurrentSound:self] stop];
  13.         if ([[TheModuleController CurrentSound:self] samplingRate]==SND_RATE_CODEC)
  14.             {[self Double8];}
  15.         else
  16.             {[self Double16];}
  17.         return self;
  18.     
  19. }
  20.  
  21.  
  22.  
  23. - Double8
  24. {
  25.     signed char *  TheArray = (signed char *)[[TheModuleController CurrentSound:self] data];
  26.     int First=0;
  27.     int Second;
  28.     int FromCounter;
  29.     int CrossingCounter;
  30.     int Size=[[TheModuleController CurrentSound:self] dataSize];
  31.     int ToCounter;
  32.     int MidPoint;
  33.  
  34.     do
  35.         {
  36.         CrossingCounter=First+2;
  37.         for (CrossingCounter=CrossingCounter+2;         (CrossingCounter<Size-1) &&  
  38.                                     !     ( (int) TheArray[CrossingCounter] >=0 && 
  39.                                     (int) TheArray[CrossingCounter+1]<=0) ;  CrossingCounter++);
  40.         Second=CrossingCounter;
  41.         if  ((Second-First)%2 !=0)
  42.             {
  43.             Second--;
  44.             }
  45.         ToCounter=First;
  46.         for (FromCounter=First  ;   FromCounter<Second  ;  FromCounter+=2)
  47.             {
  48.             TheArray[ToCounter]=TheArray[FromCounter];
  49.             ToCounter++;
  50.             }
  51.         MidPoint=First+((Second-First)/2);
  52.         for (FromCounter=First; FromCounter<MidPoint  ;   FromCounter++)
  53.             {
  54.             TheArray[FromCounter+MidPoint-First]=TheArray[FromCounter];
  55.             }
  56.         First=Second;
  57.         }
  58.     while (Second<Size-2);
  59.     [TheModuleController SoundChanged: [TheModuleController CurrentSound:self]];
  60.      return self;
  61.  
  62. }
  63.  
  64.  
  65. - Double16
  66. {
  67.     signed int *  TheArray = (signed int *)[[TheModuleController CurrentSound:self] data];
  68.     int First=0;
  69.     int Second;
  70.     int FromCounter;
  71.     int CrossingCounter;
  72.     int Size=[[TheModuleController CurrentSound:self] dataSize]/2;
  73.     int ToCounter;
  74.     int MidPoint;
  75.  
  76.     do
  77.         {
  78.         CrossingCounter=First+2;
  79.         for (CrossingCounter=CrossingCounter+2;         (CrossingCounter<Size-1) &&  
  80.                                     !     ( (int) TheArray[CrossingCounter] <=0 && 
  81.                                     (int) TheArray[CrossingCounter+1]>=0) ;  CrossingCounter++);
  82.         Second=CrossingCounter;
  83.         if  ((Second-First)%2 !=0)
  84.             {
  85.             Second--;
  86.             }
  87.         ToCounter=First;
  88.         for (FromCounter=First  ;   FromCounter<Second  ;  FromCounter+=2)
  89.             {
  90.             TheArray[ToCounter]=TheArray[FromCounter];
  91.             ToCounter++;
  92.             }
  93.         MidPoint=First+((Second-First)/2);
  94.         for (FromCounter=First; FromCounter<MidPoint  ;   FromCounter++)
  95.             {
  96.             TheArray[FromCounter+MidPoint-First]=TheArray[FromCounter];
  97.             }
  98.         First=Second;
  99.         }
  100.     while (Second<Size-2);
  101.     [TheModuleController SoundChanged: [TheModuleController CurrentSound:self]];
  102.      return self;
  103. }
  104.  
  105.  
  106.  
  107. - Halve:sender
  108. {
  109.     int n;
  110.     int a=0;
  111.     int b=0;
  112.     int z=0;
  113.     int start=0;
  114.     int t;
  115.     int Number=10;
  116.     signed short *x;
  117.     int l=[[TheModuleController CurrentSound:self] dataSize]/2;
  118.     [TheModuleController RunCompactPanel:self];
  119.        [[TheModuleController CurrentSound:self] stop];
  120.     x=(signed short *)  [[TheModuleController CurrentSound:self] data];
  121.     for (n=0;n<l;n++)
  122.     {if ((x[n+1]-x[n]>0) && (x[n]<=0) && (x[n+1]>0))
  123.         {if (start==0) {start=1;z=n;}
  124.          if (b==Number) {a=n;b++;} else
  125.             {if (b<Number*2) {b++;} else
  126.                 {for (t=a;t>z;t--)
  127.                     {x[2*t-z]=x[t];
  128.                     x[2*t-z-1]=x[t];
  129.                     }
  130.                 z=n;
  131.                 b=0;
  132.                 }
  133.             }
  134.         }
  135.     }
  136.     [TheModuleController SoundChanged: [TheModuleController CurrentSound:self]];
  137. return self;
  138. }
  139.  
  140.  
  141. @end
  142.